package com.xyrl.project.app.controller.common;

import com.xyrl.project.common.news.entity.News;
import com.xyrl.project.common.news.enums.NewtTypeEnum;
import com.xyrl.project.common.news.service.NewsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;


/**
  * @className NewsController
  * @company 星纭融链科技服务有限公司
  * @author 徐恩源
  * @version 1.0
  * @date 2019-12-26 17:01:57
  * @Description Controller
  */
@Slf4j
@Controller
@RequestMapping("/common/news")
@Api(value = "新闻资讯", tags = "公共模块")
public class NewsController {

    @Autowired
    private NewsService newsService;

    /**
     * 根据新闻资讯类型查询
     *
     * @param type
     * @author 徐恩源
     * @date 2019-12-26 15:54:48
     */
    @ApiOperation(value = "根据新闻资讯类型查询", notes = "faceVerify|人脸认证协议，userService|用户服务协议，privacyPolicy|隐私政策，loginAuth|登录认证协议")
    @ApiImplicitParam(name = "type", defaultValue = "faceVerify")
    @GetMapping("/get/{type}")
    public String get(@PathVariable("type") NewtTypeEnum type, Model model) {
        News news = newsService.queryNewsByType(type);
        model.addAttribute("news", news);
        return "newsDetail";
    }

}

